package m2;

import java.util.HashMap;

import m2.port.*;
import m2.propriete.ProprieteFonctionnel;
import m2.propriete.ProprieteNonFonctionnel;
import m2.service.ServiceFourni;
import m2.service.ServiceRequis;

public class Composant extends Element {

	protected HashMap<String, PortFourni> lesPortsFournis;
	protected HashMap<String, PortRequis> lesPortsRequis;
	protected HashMap<String, ProprieteFonctionnel> lesProprieteFonc;
	protected HashMap<String, ProprieteNonFonctionnel> lesProprieteNonFonc;
	protected HashMap<String, ServiceFourni> lesServiceFourni;
	protected HashMap<String, ServiceRequis> lesServiceRequis;
	protected Configuration configurationParent;

	public Composant(String name, Configuration parent) {
		super(name);
		this.configurationParent = parent;

		lesPortsFournis = new HashMap<String, PortFourni>();
		lesPortsRequis = new HashMap<String, PortRequis>();
		lesProprieteFonc = new HashMap<String, ProprieteFonctionnel>();
		lesProprieteNonFonc = new HashMap<String, ProprieteNonFonctionnel>();
		lesServiceFourni = new HashMap<String, ServiceFourni>();
		lesServiceRequis = new HashMap<String, ServiceRequis>();

	}

	public void addPortFournis(PortFourni p) {
		p.setComposant(this);
		lesPortsFournis.put(p.getName(), p);
	}

	public void addPortRequis(PortRequis p) {
		p.setComposant(this);
		lesPortsRequis.put(p.getName(), p);
	}

	public void addPropFonc(ProprieteFonctionnel p) {
		lesProprieteFonc.put(p.getName(), p);
	}

	public void addPropNonFonc(ProprieteNonFonctionnel p) {
		lesProprieteNonFonc.put(p.getName(), p);
	}

	public void addServiceFourni(ServiceFourni s) {
		s.setComposant(this);
		lesServiceFourni.put(s.getName(), s);
		
	}

	public void addServiceRequis(ServiceRequis s) {
		s.setComposant(this);
		lesServiceRequis.put(s.getName(), s);
		s.addObserver(this);
		
	}

	public void setConfiguration(Configuration c) {
		this.configurationParent = c;
	}

	public Configuration getConfiguration() {
		return configurationParent;
	}


	public HashMap<String, PortFourni> getLesPortsFournis() {
		return lesPortsFournis;
	}

	public void setLesPortsFournis(HashMap<String, PortFourni> lesPortsFournis) {
		this.lesPortsFournis = lesPortsFournis;
	}

	public HashMap<String, PortRequis> getLesPortsRequis() {
		return lesPortsRequis;
	}

	public void setLesPortsRequis(HashMap<String, PortRequis> lesPortsRequis) {
		this.lesPortsRequis = lesPortsRequis;
	}

	public HashMap<String, ProprieteFonctionnel> getLesProprieteFonc() {
		return lesProprieteFonc;
	}

	public void setLesProprieteFonc(
			HashMap<String, ProprieteFonctionnel> lesProprieteFonc) {
		this.lesProprieteFonc = lesProprieteFonc;
	}

	public HashMap<String, ProprieteNonFonctionnel> getLesProprieteNonFonc() {
		return lesProprieteNonFonc;
	}

	public void setLesProprieteNonFonc(
			HashMap<String, ProprieteNonFonctionnel> lesProprieteNonFonc) {
		this.lesProprieteNonFonc = lesProprieteNonFonc;
	}

	public HashMap<String, ServiceFourni> getLesServiceFourni() {
		return lesServiceFourni;
	}

	public void setLesServiceFourni(HashMap<String, ServiceFourni> lesServiceFourni) {
		this.lesServiceFourni = lesServiceFourni;
	}

	public HashMap<String, ServiceRequis> getLesServiceRequis() {
		return lesServiceRequis;
	}

	public void setLesServiceRequis(HashMap<String, ServiceRequis> lesServiceRequis) {
		this.lesServiceRequis = lesServiceRequis;
	}

	public Configuration getConfigurationParent() {
		return configurationParent;
	}

	public void setConfigurationParent(Configuration configurationParent) {
		this.configurationParent = configurationParent;
	}

	@Override
	public void update(Object o, Object arg) {
	}

}
